<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:a4j="http://richfaces.org/a4j" template="layouts/layout.xhtml">
	<ui:define name="content">
	
		<a4j:outputPanel id="mypanel">
			<rich:panel id="MyItemAddPanel">
				
				<rich:collapsiblePanel header="Configuration" switchType="client"
					expanded="false">
					<h:form>
						<h:panelGrid columns="2" styleClass="configurationTable" columnClasses="configuration">
						
						   <h:outputText value="Use Alias for Stock item : "  />
							<h:selectBooleanCheckbox value="#{wsItemController.model.itemPreferenceDTO.useAliasForItem}" />


                            <h:outputText value="Use Code for Stock item : "  />
							<h:selectBooleanCheckbox  value="#{wsItemController.model.itemPreferenceDTO.useCodeForItem}" />
							  <h:outputText value="Use Description for Stock item : " />
							<h:selectBooleanCheckbox  value="#{wsItemController.model.itemPreferenceDTO.useDescForItem}"/>
							  <h:outputText value="Use Remarks for Stock item : " />
							<h:selectBooleanCheckbox  />
							  <h:outputText value="Allow Marked price for Stock item :" />
							<h:selectBooleanCheckbox  value="#{wsItemController.model.itemPreferenceDTO.enaleMarekedPriceForItem}" />
							
							 <h:outputText value="Use Address for Godowns(Store location)" />
							<h:selectBooleanCheckbox value="#{wsItemController.model.itemPreferenceDTO.enableGowDownsForItem}" />
							
							<h:outputText value="Use Vendor for Stock item " />
							<h:selectBooleanCheckbox value="#{wsItemController.model.itemPreferenceDTO.enableVendorForItem}" />
							
							<h:outputText value="Enable Different Costing method :" />
							<h:selectBooleanCheckbox value="#{wsItemController.model.itemPreferenceDTO.enableDifferentCostingType}" />
							
							
							<h:outputText value="Number of Digit to use for roundUp : " />
							<h:inputText size="3" id="digit" value="#{wsItemController.model.itemPreferenceDTO.roundUpDigit}" style="font-size:11px" />

								
							<h:outputText value="This ways configuration will done " />


						</h:panelGrid>


						<h:panelGrid columns="3">
							<a4j:commandButton type="submit"
								actionListener="#{wsItemController.updateUserPreference}"
								render="mypanel" value="Apply" />


						</h:panelGrid>
					</h:form>
				</rich:collapsiblePanel>
				

				<h:panelGrid styleClass="stockInTableHeader" columns="3">
				
					
              
           
                  <h:outputText value="Item Name: " />
                  <rich:select styleClass="itemList"  enableManualInput="true"
									listHeight="500px" listWidth="350px" id="Item" label="item"
									value="#{wsItemController.model.itemID}" defaultLabel="------------Select-------------"
									required="true" requiredMessage="Please select Item">
									<a4j:ajax event="selectitem"
										listener="#{wsItemController.selectedItem}"
										render="myRightSidePanel" />
									<f:selectItems value="#{wsItemController.model.wsItemDTOs}" var="item"
										itemLabel="#{item.itemName} [#{item.itemCode}]"
										itemValue="#{item.itemID}" />
								</rich:select>
								<rich:message  for="Item"/>
								

				</h:panelGrid>
				
				
				<h:panelGrid styleClass="itemTable1" columns="2"
					columnClasses="ecol1, ecol2">


					<h:panelGrid columns="4">





						
                        
                        <h:outputText value="Impact on Stock:" />
					<h:selectBooleanCheckbox
						value="#{wsItemController.model.hasImpactOnStock}" />
					<a4j:commandLink value="" />
					<a4j:commandLink value="" />
                        

						<h:outputText value="Unit :" />
						<h:inputText id="unit" value="Not Applicable" />
						<rich:message for="unit" />
						 <h:inputHidden value="#{wsItemController.model.unitDTO.markedPriceUnitID}" id="unitHiddenField" />
						 
						 	<h:outputText value="Marked Price :" />
						<h:inputText id="mp" value="#{wsItemController.model.markedPrice}" />
						<rich:message for="mp" />
						 <h:inputHidden  id="mpHiddenField" />
						

						

						





					</h:panelGrid>
					<h:panelGrid columns="3">


						<h:outputText styleClass="Tax" value="Tax Information " />
						<h:outputText value="" />
						<h:outputText value="" />
						
						
						<h:outputText value="Duty Fee:"/>
						<h:inputText  value="#{wsItemController.model.dutyFee}" size="10"  />
						


					</h:panelGrid>







				</h:panelGrid>

				<h:panelGrid styleClass="itemTableFooter" columns="6">
					<h:outputText styleClass="Total" value="Total Balance " />
					<h:outputText value="Quantity: " />
					<h:outputText value="Rate: " />
					<h:outputText value="Per: " />
					<h:outputText value=""  style="width:10px" />
					
					
					<h:outputText value="Value:  " />

					
					<h:outputText value="" />
					<h:inputText id="itemQuantity"
						value="#{wsItemController.model.quantity}" required="true" style="width:40px"
						requiredMessage="Not blank " />
						
						
						
					<h:inputText id="itemRate" value="#{wsItemController.model.unitPrice}"  style="width:40px"
						requiredMessage="Not blank " />

                   <h:inputText id="itemPerUnit"  style="width:80px" 
						requiredMessage="Not blank " />
						<h:inputHidden  id="itemPerUnitHiddenField" value="#{wsItemController.model.unitDTO.unitID}" />
					

					<h:inputText name="totalPrice" id="totalPrice" value="#{wsItemController.model.totalPrice}" style="width:70px"
						minInputWidth="100px;" />


				</h:panelGrid>


 <h:panelGrid columns="3">
				<a4j:commandButton type="submit" 
					actionListener="#{wsItemController.addItem}"   value="Save Item"
					render="mypanel,myRightSidePanel" />
				<h:outputText value="&#160;&#160;&#160;" />
				<a4j:commandButton type="button"
					actionListener="#{wsItemController.reSet}" value="Reset"
					render="mypanel" immediate="true" />
</h:panelGrid>

			</rich:panel>


<script type="text/javascript">
		
		   //<![CDATA[
		              
		          
		
		
			jQuery(document).ready(function(e) {
				
				
				
				
				
				
				var hideAndShow= [#{rich:element('group')}, #{rich:element('groupHiddenField')},    #{rich:element('allGroups')}];
				var hideAndShow1= [#{rich:element('unit')}, #{rich:element('unitHiddenField')},        #{rich:element('allUnits')}];
				var hideAndShow2= [#{rich:element('itemValuation')}, #{rich:element('itemValuationHiddenField')}, #{rich:element('allItemValuation')}];
				var hideAndShow3= [#{rich:element('unitM')}, #{rich:element('unitMHiddenField')},        #{rich:element('allUnits1')}];
				var hideAndShow4= [#{rich:element('item')}, #{rich:element('itemHiddenField')},        #{rich:element('allItems')}];
				var hideAndShow5= [#{rich:element('itemPerUnit')}, #{rich:element('itemPerUnitHiddenField')},        #{rich:element('allItemsPerUnit')}];
				
				
				
				jQuery(hideAndShow1[0]).val("");
				jQuery(hideAndShow2[0]).val("");
				jQuery(hideAndShow3[0]).val("Not Applicable");
				jQuery(hideAndShow4[0]).val("");
				jQuery(hideAndShow5[0]).val("");
				
				
				//]]>
				
				</script>			
							

	


		</a4j:outputPanel>


	</ui:define>
	<ui:define name="rightsidebar">

	<a4j:outputPanel id="myRightSidePanel">

<h:form>
         
			
			
			
			<h:selectOneListbox  styleClass="mycustomscroll" label="allUnits" id="allUnits"  style="display:none"  >
						<f:selectItems value="#{wsItemController.model.wsUnitDTOs}"
							var="unit" itemLabel="#{unit.unitName}"
							itemValue="#{unit.unitID}" />
					</h:selectOneListbox>
					
				<h:selectOneListbox styleClass="mycustomscroll"  id="allItemsPerUnit"  style="display:none"  >
						<f:selectItems value="#{wsItemController.model.wsUnitDTOs}"
							var="unit" itemLabel="#{unit.unitName}"
							itemValue="#{unit.unitID}" />
					</h:selectOneListbox> 
					
			
			
	</h:form>	
	
	<script type="text/javascript">
		
		   //<![CDATA[
		              
		          
		
		
			jQuery(document).ready(function(e) {
				
				
				
				
				
				
				var hideAndShow= [#{rich:element('group')}, #{rich:element('groupHiddenField')},    #{rich:element('allGroups')}];
				var hideAndShow1= [#{rich:element('unit')}, #{rich:element('unitHiddenField')},        #{rich:element('allUnits')}];
				var hideAndShow2= [#{rich:element('itemValuation')}, #{rich:element('itemValuationHiddenField')}, #{rich:element('allItemValuation')}];
				var hideAndShow3= [#{rich:element('unitM')}, #{rich:element('unitMHiddenField')},        #{rich:element('allUnits1')}];
				var hideAndShow4= [#{rich:element('item')}, #{rich:element('itemHiddenField')},        #{rich:element('allItems')}];
				var hideAndShow5= [#{rich:element('itemPerUnit')}, #{rich:element('itemPerUnitHiddenField')},        #{rich:element('allItemsPerUnit')}];
				
				
				
				jQuery(hideAndShow1[0]).val("");
				jQuery(hideAndShow2[0]).val("");
				jQuery(hideAndShow3[0]).val("Not Applicable");
				jQuery(hideAndShow4[0]).val("");
				jQuery(hideAndShow5[0]).val("");
				

				

				jQuery(hideAndShow1[0]).click(function() {

					jQuery(hideAndShow1[2]).show();
					jQuery(hideAndShow[2]).hide();
					jQuery(hideAndShow2[2]).hide();
					jQuery(hideAndShow3[2]).hide();
					jQuery(hideAndShow4[2]).hide();
					jQuery(hideAndShow5[2]).hide();

				});

				jQuery(hideAndShow1[2]).click(function() {

					var id = jQuery(this).val();
					var text = jQuery(this).find(':selected').text();
					jQuery(hideAndShow1[0]).val(text);
					jQuery(hideAndShow1[1]).val(id);

				});

				

				jQuery(hideAndShow3[0]).click(function() {

					jQuery(hideAndShow3[2]).show();
					jQuery(hideAndShow[2]).hide();
					jQuery(hideAndShow1[2]).hide();
					jQuery(hideAndShow2[2]).hide();
					jQuery(hideAndShow4[2]).hide();
					jQuery(hideAndShow5[2]).hide();

				});

				jQuery(hideAndShow3[2]).click(function() {

					var id = jQuery(this).val();
					var text = jQuery(this).find(':selected').text();
					jQuery(hideAndShow3[0]).val(text);
					jQuery(hideAndShow3[1]).val(id);

				});

				
				
				jQuery(hideAndShow5[0]).click(function() {

					jQuery(hideAndShow5[2]).show();
					jQuery(hideAndShow[2]).hide();
					jQuery(hideAndShow1[2]).hide();
					jQuery(hideAndShow2[2]).hide();
					jQuery(hideAndShow3[2]).hide();
					jQuery(hideAndShow4[2]).hide();

				});

				jQuery(hideAndShow5[2]).click(function() {

					var id = jQuery(this).val();
					var text = jQuery(this).find(':selected').text();
					jQuery(hideAndShow5[0]).val(text);
					jQuery(hideAndShow5[1]).val(id);

				});
				
				
				/* this is the method which evaluated the total value from item quantity and unit price */

				
				var itemQuantity=#{rich:element('itemQuantity')};
				var ratePerUnit=#{rich:element('itemRate')};
				var totalPrice=#{rich:element('totalPrice')};
				jQuery(itemQuantity).keyup(function() {
					

					var  quantity=jQuery(itemQuantity).val(); 
					var unitRate=jQuery(ratePerUnit).val();
					var tprice=jQuery(totalPrice).val();
				    
					var calPrice=unitRate * quantity;
					
					
						jQuery(totalPrice).val(calPrice);
						
						
					
					
				});
				
				
				jQuery(ratePerUnit).keyup(function() {
					

					var  quantity=jQuery(itemQuantity).val(); 
					var unitRate=jQuery(ratePerUnit).val();
					var tprice=jQuery(totalPrice).val();
				    
					var calPrice=unitRate * quantity;
					
					
						jQuery(totalPrice).val(calPrice);
						
										
					
					
				});
				
					jQuery(totalPrice).keyup(function() {
					

					var  quantity=jQuery(itemQuantity).val(); 
					var unitRate=jQuery(ratePerUnit).val();
					var tprice=jQuery(totalPrice).val();
				    
					var calPrice=unitRate * quantity;
					var calRate= tprice / quantity;
					
					
						jQuery(ratePerUnit).val(calRate);
						
						
						
						
					
					
				});


				

			});
		
		
		
		
		              
		  //]]>
		
</script>			
					
					
				
</a4j:outputPanel>

		
	</ui:define>

	<ui:define name="js">

	</ui:define>
</ui:composition>
